fix: strip parameters from data content types to assess if it's JSON format#484
Conversation
|
Fixes #481 |
|
** This may apply to much more than just the JSON format serialization. Don't the various transport bindings also check for content-type such as application/cloudevents+json ?? theoretically those checks should also include this type of stripping. I'm not sure if now is the time but we may want to break all of this stuff out into a some core utilities that can be shared across all of the formats and transports .. most specifically "take a content-type and strip off all the trailing attributes" and "isJson(stripped-content-type)" type functions. Not sure if we should address this now or add it as a followup .. it might need a bit more analysis to see where everybody is doing a comparison on content-type. |
5a1c42d to
00a37de
Compare
|
@JemDay I'm not sure this comment is directed to me but... it makes sense to me, for the potential to be needed elsewhere. However, I'm not familiar with this particular project, so I'd individually prefer to defer refactoring in a different context than this PR. |
JemDay
left a comment
There was a problem hiding this comment.
LGTM .. simplifying the regex would be nice for efficient processing but could be a follow-on activity.
| * JSON Data Content Type Discriminator | ||
| */ | ||
| private static final Pattern JSON_CONTENT_TYPE_PATTERN = Pattern.compile("^(application|text)\\/([a-zA-Z]+\\+)?json$"); | ||
| private static final Pattern JSON_CONTENT_TYPE_PATTERN = Pattern.compile("^(application|text)\\/([a-zA-Z]+\\+)?json(;[\\s\\w\"!#$%&'*+.^_`{|}~=-]*)*$"); |
There was a problem hiding this comment.
I wonder if this regex can be simplified so that it simply matches anything following the ";" so something like "(;.*)*$" - my regex may be a bit rusty. ;-)
There was a problem hiding this comment.
Thanks, I was overdoing it :)
…format Signed-off-by: Frederic Delechamp <fdelechamp@guidewire.com>
4d42d08 to
04fd4b8
Compare
|
Thanks @fredoboulo! |
|
@fredoboulo would you be willing to backport the merged commit 6362bfb to the 2.4 branch for a patch release? |
|
Hi @pierDipi, that's about cherry-picking and making a PR in branch 2.4? |
cloudevents#484) Signed-off-by: Frederic Delechamp <fdelechamp@guidewire.com>
Fixes #481
Signed-off-by: Frederic Delechamp fdelechamp@guidewire.com